/**
 * SQL构建器模块
 * 提供SQL语句构建功能，支持类型安全的SQL操作
 */

// 导出类型
export * from './types';

// 导出构建器
export { SqlBuilder } from './SqlBuilder';
export { SelectBuilder } from './SelectBuilder';
export { InsertBuilder } from './InsertBuilder';
export { UpdateBuilder } from './UpdateBuilder';
export { DeleteBuilder } from './DeleteBuilder';
export { ConditionBuilder } from './ConditionBuilder';
export { TableBuilder } from './TableBuilder';

// 导出执行器接口和实现
export { BetterSqliteExecutor } from './SqlExecutor';

// 方便用户使用的快捷函数
import { SqlBuilder } from './SqlBuilder';
import { BetterSqliteExecutor } from './SqlExecutor';
import { Database } from 'better-sqlite3';
import BetterSqlite from 'better-sqlite3';

/**
 * 创建SQL构建器
 * @param tableName 表名（可选）
 * @returns SQL构建器实例
 */
export function createSqlBuilder<T = any>(tableName: string = ''): SqlBuilder<T> {
  return new SqlBuilder<T>(tableName);
}

/**
 * 创建一个与better-sqlite3数据库连接的执行器
 * @param db 数据库连接或文件路径
 * @param options 选项
 * @returns SQL执行器实例
 */
export function createExecutor(
  db: Database | string, 
  options: { debug?: boolean } = {}
): BetterSqliteExecutor {
  const database = typeof db === 'string' ? new BetterSqlite(db) : db;
  return new BetterSqliteExecutor(database, options);
} 